package com.xtwy.dao;


import com.xtwy.entity.UserInfo;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.CrudRepository;
import org.springframework.data.repository.query.Param;

import java.util.List;

public interface UserInfoDao extends CrudRepository<UserInfo,Long> {
    /**通过username查找用户信息;*/
    UserInfo findByUsername(String username);
    /***通过用户名查询角色*/
    @Query(nativeQuery = true,value="SELECT u.username,r.role,ur.uid,u.name,u.password,u.salt,u.state,r.role FROM user_info u,sys_role r,sys_user_role ur WHERE ur.uid=u.uid and ur.role_id=r.id and u.username=?1")
    UserInfo findUserInfoAndSysRole(@Param("username") String username);
}